package com.example.easypoi.service;


import com.example.easypoi.entity.*;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;

@Service
public class UserReportService {

    public List<User> buildMockData() {
        List<User> users = new ArrayList<>();

        for (long i = 1; i <= 5; i++) {
            User user = new User();
            user.setId(i);
            user.setName("用户" + i);
            user.setPhone("1380000000" + i);
            user.setEmail("user" + i + "@example.com");
            user.setAvatarPath("static/avatar.png");

            /* 1. 部门 */
            Department dept = new Department();
            dept.setDeptName("技术部");
            user.setDepartment(dept);

            /* 2. 订单列表：这里造 3 条订单 */
            List<Order> orders = new ArrayList<>();
            for (int j = 1; j <= 3; j++) {
                Order order = new Order();
                order.setOrderNo("ORD" + i + "-" + j);
                order.setOrderTime(new Date());
                order.setAmount(new BigDecimal("199.99").multiply(BigDecimal.valueOf(j)));

                /* 3. 每条订单再配 2 个商品 */
                List<Product> products = new ArrayList<>();
                for (int k = 1; k <= 2; k++) {
                    Product p = new Product();
                    p.setName("商品" + k);
                    p.setPrice(new BigDecimal("100").multiply(BigDecimal.valueOf(k)));
                    p.setQuantity(k);
                    products.add(p);
                }
                order.setProducts(products);
                orders.add(order);
            }
            user.setOrders(orders);
            users.add(user);
        }
        return users;
    }

}